package cn.liujianbo.example.springbean.bean6;

import cn.liujianbo.example.springbean.bean6.component.AppConfig;
import cn.liujianbo.example.springbean.bean6.component.UserService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author 刘建波
 * @date 2021-10-11 23:44
 * 事务
 * 1. DataSource
 * DriverManagerDataSource dataSource = new DriverManagerDataSource();
 * dataSource.setUrl("jdbc:mysql://192.168.56.105:3306/test");
 * dataSource.setUsername("root");
 * dataSource.setPassword("root");
 * 2. JdbcTemplate
 * return new JdbcTemplate(dataSource);
 * 3. platformTransactionManager
 * new DataSourceTransactionManager(dataSource);
 * 4. 启用事务 @EnableTransactionManagement
 * <p>
 * todo 测试同一个bean事务方法嵌套调用
 */
public class Test {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        UserService userService = context.getBean(UserService.class);
        userService.test();
    }
}
